<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>职位描述</title>
	<link rel="stylesheet" href="../css/work_detail.css">
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="shortcut icon" href="../img/title/招聘求职.png" type="image/x-icon">
</head>
<body>
    <div id="app" v-loading="loading">
		<div class="header">
			<div class="header_left">
				<img src="../img/main/招聘会.png"	>
				<a href="./main.html">&nbsp;校园兼职管理</a>
			</div>
			<div class="header_center">
				<ul>
					<li ><a href="./main.html">主页</a></li>
					<li><a style="color: lawngreen;" href="./work_list.html">职位</a></li>
					<li><a href="./news.html">校园新闻</a></li>
				</ul>
			</div>
			<div class="header_right">
				<el-button @click="loginBtn" type="success" icon="el-icon-user-solid">登录</el-button>
				<el-button @click="registerBtn" type="success" icon="el-icon-takeaway-box">注册</el-button>
			</div>
		</div>
		<div class="section">
			<div class="section_1">职位描述</div>
			<div class="section_2">首页 > 职位描述</div>
		</div>
		<div class="content">
			<div class="content_left">
				<div class="content_left_header">
					<div class="content_left_header_left">
						<el-avatar :size="90" :src="this.dataList.job.job_image"></el-avatar>
						<el-tag type="success">{{this.dataList.job.job_name}}</el-tag>
						<span>{{this.dataList.job.job_address}}</span>
						<el-button @click="sendResume" type="success">投递简历</el-button>
					</div>
					<div class="content_left_header_right">
						<ul style="width: 85%;height: 85%;display: flex;flex-direction: column;justify-content: space-around;">
							<li style="color: darkred;"><i class="el-icon-user"></i>&nbsp;&nbsp;&nbsp;{{this.dataList.jobJoin.principal}}</li>
							<li style="color: darkred;"><i class="el-icon-mobile"></i>&nbsp;&nbsp;&nbsp;{{this.dataList.jobJoin.phone}}</li>
							<li style="color: darkred;"><i class="el-icon-receiving"></i>&nbsp;&nbsp;&nbsp;{{this.dataList.jobJoin.email}}</li>
							<li style="color: green"><i class="el-icon-collection-tag"></i>&nbsp;&nbsp;&nbsp;{{this.dataList.job.job_type}}</li>
							<li style="color: green;"><i class="el-icon-edit-outline"></i>&nbsp;&nbsp;&nbsp;{{this.dataList.job.job_price}}</li>
							<li style="color: green;"><i class="el-icon-more-outline"></i>&nbsp;&nbsp;&nbsp;{{this.dataList.job.job_status}}</li>
						</ul>
					</div>
				</div>
				<div class="content_left_section">
					<div class="content_left_section_header">
						<p>岗位职责</p>
					</div>
					<div class="content_left_section_content">
						<p>{{this.dataList.job.job_description}}</p>
					</div>
				</div>
				<div class="content_left_footer">
					<div class="content_left_footer_header">
						<p>任职要求</p>
					</div>
					<div class="content_left_footer_content">
						<p>{{this.dataList.job.job_responsibility}}</p>
					</div>
				</div>
			</div>
			<div class="content_right">
				<div class="content_right_top">
					<div class="content_right_top_header">
						<img src="../img/work_detail/地点.png" style="width: 15%;margin-left: 5%"/>
						<div style="font-weight: bold;font-size: 1.375rem">&nbsp;{{this.dataList.job.job_address}}</div>
					</div>
					<div class="content_right_top_content">
						<ul style="width: 100%;height: 100%;display: flex;flex-direction: column;justify-content: space-around;">
							<li><i class="el-icon-user-solid"></i>&nbsp;&nbsp;&nbsp;&nbsp;{{this.dataList.job.job_name}}</li><hr color="#e3e3e3">
							<li><i class="el-icon-s-finance"></i>&nbsp;&nbsp;&nbsp;&nbsp;{{this.dataList.job.job_price}}</li><hr color="#e3e3e3">
							<li><i class="el-icon-warning"></i>&nbsp;&nbsp;&nbsp;&nbsp;{{this.dataList.job.job_experience}}</li><hr color="#e3e3e3">
							<li><i class="el-icon-s-management"></i>&nbsp;&nbsp;&nbsp;&nbsp;{{this.dataList.job.job_education}}</li><hr color="#e3e3e3">
							<li><i class="el-icon-s-grid"></i>&nbsp;&nbsp;&nbsp;&nbsp;{{this.dataList.job.job_welfare}}</li><hr color="#e3e3e3">
						</ul>
					</div>
				</div>
				<div class="content_right_bottom">
					<div class="content_right_bottom_header">
						<img src="../img/work_detail/资料库.png" style="width: 15%;margin-left: 5%"/>
						<div style="font-weight: bold;font-size: 1.375rem">&nbsp;公司</div>
					</div>
					<div class="content_right_bottom_bottom">
						<ul style="width: 100%;height: 100%;border-radius: 0 0 15px 15px;display: flex;flex-direction: column;justify-content: space-around;">
							<li><i class="el-icon-user-solid"></i>&nbsp;&nbsp;&nbsp;&nbsp;{{this.dataList.jobJoin.principal}}</li><hr color="#e3e3e3">
							<li><i class="el-icon-s-home"></i>&nbsp;&nbsp;&nbsp;&nbsp;{{this.dataList.jobJoin.company}}</li><hr color="#e3e3e3">
							<li><i class="el-icon-date"></i>&nbsp;&nbsp;&nbsp;&nbsp;{{this.dataList.jobJoin.start_time}}</li><hr color="#e3e3e3">
						</ul>
					</div>
				</div>
			</div>
		</div>
    </div>
</body>

<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="../js/jquery-3.6.1.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script src="../js/after_landing.js"></script>
<script>
    const vm = new Vue({
        el: '#app',
        data(){
            return {
                dataList: [],
				userMsgList : [],
				loading : true,
            }
        },
		methods:{
			loginBtn(){
				document.location.href = "login.html"
			},
			registerBtn(){
				document.location.href = "register.html"
			},
			async sendResume(){
				//先判断cookie中有没有用户的信息 如果没有则会跳转至登陆界面
				let username = getCookie("cookie_username");
				if (username !== null && username.length >0){
					//根据用户id得到该用户的简历信息 如果简历信息为空 将会跳转至简历界面
					axios.get('/jobs/getResumeByUserId/'+this.userMsgList.id).then((resp)=>{
						let userResumeMsg = resp.data.data
						if (userResumeMsg === null) {
							document.location.href = "personal_resume.html"
						} else {
							//有简历信息的情况下
							let params = this.dataList.jobJoin.jid + "/"
							params += this.userMsgList.id + "/"
							params += this.userMsgList.id
							console.log(this.dataList.jobJoin.jid,this.userMsgList.id,this.userMsgList.id)
							axios.get("/jobs/getResume/"+params).then((resp)=>{
								let userAndCompany = resp.data.data
								if (userAndCompany === null) {
									axios.post("/jobs/sendResume/"+params).then((resp)=>{
										let xy = resp.data.data
										if (xy === null){
											this.$message.error("服务器出错 联系管理员")
										} else {
											this.$message({
												type: 'success',
												message: "简历投递成功，可在 个人中心->投递过的岗位 查看最新的已投简历信息",
												showClose: true,
											})
										}
									})
								}
								//投递库中有该用户且简历在审核中
								if (userAndCompany.audit_status === '审核中'){
									this.$message({
										type: 'warning',
										message: '还在审核中哦，可在 个人中心->投递过的岗位 查看最新的已投简历信息',
										showClose: true,
									})
								} else if (userAndCompany.audit_status === '已入职') {
									this.$message({
										message: "已入职了哦 无需申请",
										showClose: true,
									})
								} else if (userAndCompany.audit_status === '沟通中'){
									this.$message({
										type: 'warning',
										message: "已处在沟通中的状态 无需重复申请",
										showClose: true,
									})
								} else if (userAndCompany.audit_status === '已拒绝'){
									this.$message({
										type: 'error',
										message: "该简历已被拒绝，请寻找其他岗位",
										showClose: true,
									})
								}
							})
						}
					})
					//投送简历保存数据库中 公司id 用户id 简历id(需要多表查询 判断用户id于简历中的用户id相等)
				} else {
					document.location.href = "login.html"
				}
			},
		},
        async created(){
            let id = window.sessionStorage.getItem('id');
           	await axios.get("/jobs/getAllInformation/"+id).then((resp)=>{
                this.dataList = resp.data.data;
            })
			let username = getCookie("cookie_username")
			if (username !== null && username.length > 0){
				await axios.get('/users/'+username).then((resp)=>{
					this.userMsgList = resp.data.data
					$('.header_center ul').append(`<li><a href="./personal_resume.html">简历</a></li>`)
					$('.header_center ul').append(`<li><a href="./personal_center.html">个人中心</a></li>`)
					$('.header_right').empty()
					let url = this.userMsgList.user_image
					$(".header_right").append(`<img style="width: 7%;margin-right: 5px" src="${url}">${username}`);
					$(".header_right").append(`<a style="text-decoration: none;color: #77838e;margin-left: 5px" href="/logins/logout">注销</a>`);
				})
			} else {
				$('.header_center ul li:gt(2)').remove()
			}
			this.loading = false
        }

    })
</script>
</html>